﻿using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using WindowsPhoneMVC.Navigation;

namespace WindowsPhoneMVC.Tests.Navigation
{
    [TestClass]
    public class DeepLinkTests
    {
        [TestMethod]
        public void GeneratesDeepLinkUri()
        {
            // arrange
            const string controller = "testcontroller";
            const string action = "someaction";

            // act
            var deeplink = DeepLink.UriFor(controller, action, new Dictionary<string, string>
                                                     {
                                                         {"param1", "somevalue"}
                                                     });

            // assert
            Assert.AreEqual(string.Format("/Shell.xaml?controller={0}&action={1}&param1=somevalue", controller, action), deeplink);
        }

        [TestMethod]
        public void DecodesUriIntoRequest()
        {
            // arrange
            const string controller = "testcontroller";
            const string action = "someaction";

            // act
            var request = DeepLink.DecodeUri("", new Dictionary<string, string>{{"controller", controller}, {"action", action}, {"param1", "somevalue"}});

            // assert
            Assert.AreEqual(controller, request.ControllerName);
            Assert.AreEqual(action, request.ActionName);
        }
    }
}